package domain;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
//import java.util.*;

import kb.DescriptionLogicsKB;
import utils.Util;
import utils.io.KBAccess;
import entities.Individual;
import entities.assertion.ConceptAssertion;
//import entities.concept.AndConcept;
import entities.concept.Concept;
//import entities.concept.DomainConcept;
//import entities.concept.DomainConceptEQ;
//import entities.concept.DomainConceptLT;
//import entities.concept.DomainConceptLTEQ;
import entities.concept.PConcept;

//import entities.role.Role;

/**
 * This class builds a feature concept graph to determine the clashes. with
 * three operators, there are 8 cases to consider clashes (in fact seven as it
 * is impossible to have no ops) a path with all <: clash a path with all <=: no
 * all =: no = <=: no < <=: clash < =: clash < = <=: clash hence: when no (less
 * than <) is present in the path, there will be no clash!
 * 
 * for equality clash: f=k1 and f=k2, use a different method
 * 
 * NB. when add f=g, must add g=f;
 * 
 * @author Enoch
 * 
 */
public class TestGraph {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String prefix = "";
		String fileloc = prefix + "testkb.kb";
		DescriptionLogicsKB kb = null;
		try {
			FileReader fr = new FileReader(fileloc);
			BufferedReader br = new BufferedReader(fr);
			kb = KBAccess.processKBFile(
					br,
					false,
					fileloc.substring(fileloc.lastIndexOf('/') + 1,
							fileloc.lastIndexOf('.')));
		} catch (Exception e) {
			e.printStackTrace();
		}
		Concept ca = PConcept.getPConcept("C");
		ConceptAssertion rhs = new ConceptAssertion(
				Individual.newIndividual("a"), ca);
		boolean test = Util.assertionCheck(null, rhs, kb);
		System.out.println("Checking if entailed (" + rhs + ") -> " + test);
		// FeatureGraph fg = new FeatureGraph();
		// fg.buildGraph(s);
		// if(fg.clashFinder()){
		// System.out.println("\nClash found");
		// }else{
		// System.out.println("\n No Clash found");
		// }

		// Concept aa=new PConcept("A");
		// Concept bb=new PConcept("A");
		// Concept aa=new DomainConceptLT<Role, String>(new Role("R"), "s555");
		// Concept bb=new DomainConceptLT<Role, String>(new Role("R"), "555");
		// HashSet<Concept> set1 = new HashSet<Concept>();
		// set1.add(aa);
		// set1.add(bb);
		// Concept and1 = new AndConcept(set1);
		// HashSet<Concept> set2 = new HashSet<Concept>();
		// set2.add(aa);
		// set2.add(bb);
		// Concept and2 = new AndConcept(set2);
		// HashSet<Concept> c1 = new HashSet<Concept>();
		// c1.add(and1);
		// HashSet<Concept> c2 = new HashSet<Concept>();
		// c2.add(and2);
		//
		// if(Collections.disjoint(c1, c2)){
		// System.out.println("disjoint");
		// }else{
		// System.out.println("common elements found");
		// }
		/*
		 * for(Vertex v:fg.vertices){
		 * System.out.println("Now testing: "+v.renderDomainObject());
		 * if(v.computeEQClash(v)) System.out.println("clash"); else{
		 * System.out.println("no clash"); } String eq =
		 * "\n"+v.renderDomainObject() + " equals to: "; for(Vertex
		 * vv:v.equivalenceSet){ eq += vv.renderDomainObject()+"; "; }
		 * System.out.println(eq); }
		 */
	}

}
